﻿namespace Behaving.Decorators
{
    public class WaitCounter : Decorator
    {
        private int _currentCount;
        public WaitCounter(Behaviour behaviour, int ticksToWait)
            : base(behaviour)
        {
            TicksToWait = ticksToWait;
        }

        public int TicksToWait { get; set; }

        public override RunningState Execute(BehaviourTree behaviourTree)
        {
            if (_currentCount < TicksToWait)
            {
                _currentCount++;
                return RunningState.Running;
            }
            _currentCount = 0;
            return Behaviour.Tick(behaviourTree);
        }
    }
}